<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="purchase.domain.Purchase"%>
<%@ page import="purchase.util.*"%>

<% 
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>task_list</title>
<script type="text/javascript" src="<%=path %>/purchase/Toolkit.js"></script>
</head>
<body>
<table align="center" border="1">
	<tr align="center">
		<td colspan="5"><b><font color="red">My Task List</font></b></td>
	</tr>
	<tr>
		<th>Id</th>
		<th>Title</th>
		<th>Remark</th>
		<th>IssuePerson</th>
		<th>&nbsp;</th>
		<th>Status</th>
	</tr>
	
	<% 
		List<Purchase> purchaseTaskList = (List<Purchase>)request.getAttribute("purchaseTaskList");
	
		for (int i=0; i<purchaseTaskList.size(); i++) {
			Purchase purchase = purchaseTaskList.get(i);
			Long id = purchase.getId();
			String title = purchase.getTitle();
			String remark = purchase.getRemark();
			String issuePerson = purchase.getTaskBean().getProcessInstanceCreater();
			String processStatus = purchase.getTaskBean().getCurrentProcessStatus();
			Long tokenId = purchase.getTaskBean().getTokenId();
			Long taskInstanceId = purchase.getTaskBean().getTaskInstanceId();
			
			String url =  path+"/purchase/";
			
			if (PurchaseConstants.PROCESS_MANAGER_APPROVE.equals(processStatus)) {
				url += "inputMgrApprovePurchase.do";
			} else if (PurchaseConstants.PROCESS_ISSUEPERSON_CANCEL.equals(processStatus)) {
				url += "inputCancelPurchase.do";
			} else if (PurchaseConstants.PROCESS_ISSUEPERSON_MODIFY.equals(processStatus)) {
				url += "inputModifyPurchase.do";
			} 
			
			url += "?purchaseId="+id+"&taskId="+taskInstanceId;
	%>
	<tr>
		<td><%=id %></td>
		<td><%=title %></td>
		<td><%=remark %></td>
		<td><%=issuePerson %></td>
		<td><a href="#" onclick="processImage('<%=path %>/jbpmProcessImagePositionServlet.jbpm?tokenId=<%=tokenId %>');">ProcessImage</a></td>
		<td>
			<a href="<%= url %>"><%=processStatus %></a>
		</td>
	</tr>
	<% 
		}
	%>
	
</table>
</body>
</html>